package com.china08.yxyapi.api.manage.tec.teaching.scoreport.compareexam;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.service.mg.impl.ExamServiceImpl;

/**
 * 考试成绩年级比较
 * 
 */
@CrossOrigin
@RestController
public class CompareExamController {

    @Autowired
    private ExamServiceImpl examServiceImpl;

    @RequestMapping(value = "/api_yw/manage/tec/teaching/scoreport/compareexam/compare", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel process(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel model) {

        model.check();
        RespModel respModel = examServiceImpl.compareExam(model.idLst, model.id);
        return respModel;
    }

    /**
     * 请求参数
     * 
     */
    protected static class ReqModel extends YxyApiReqModel {
        // 考试列表
        public List<String> idLst;
        // 本班考试id
        public String id;

        public void check() {
            Assert.notNull(StringUtils.defaultIfBlank(id, null), "考试编号不能为空");
        }
    }

    /**
     * 响应参数
     * 
     */
    public static class RespModel extends YxyApiRespModel {
        // 试卷难度
        public String difficultValue;

        // 班级试卷难度排序
        public List<classScoreSk> classSkLst;

        // 学生成绩列表
        public List<StuScore> StuScoreLst;

        // 优良雷达图
        public Map<Integer, Double> fineRank;
        // 分布分析
        public String rankRemark;

        // 试卷合理性？
    }

    public static class classScoreSk {
        // 偏度系数
        public Double skValue;
        // 班级名称
        public String className;
    }

    public static class StuScore {
        // 学生id
        public String stuId;
        // 学生姓名
        public String stuName;
        // 学生本题的分数
        public Double score;
        // 学生在学校排名
        public Integer index;
    }
}
